//
//  ECMineTableViewCell.m
//  Edu_iOS2018
//
//  Created by apple on 2018/1/6.
//  Copyright © 2018年 yanyan. All rights reserved.
//

#import "ECMineTableViewCell.h"

@interface ECMineTableViewCell(){
    UIImageView *iconImageView;
    UILabel *titleLab;
    UIImageView *arrowImageView;
    UIView *lineView;
}


@end

@implementation ECMineTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        //布局cell内部控件
        [self setupUI];
    }
    return self;
}

-(void)setupUI{
    iconImageView = [[UIImageView alloc]init];
    [self.contentView addSubview:iconImageView];
    
    titleLab = [[UILabel alloc]init];
    [self.contentView addSubview:titleLab];
    titleLab.font = [UIFont systemFontOfSize:15*kPercentage];
    titleLab.textColor = [UIColor colorWithHexString:@"#1A1A1A"];
    
    arrowImageView = [[UIImageView alloc]init];
    [self.contentView addSubview:arrowImageView];
    arrowImageView.image = [UIImage imageNamed:@"Mine_arrow"];
    
    lineView = [[UIView alloc]init];
    [self.contentView addSubview:lineView];
    lineView.backgroundColor = [UIColor colorWithHexString:@"#F2F2F2"];
    
    WeakSelf(weakSelf);
    [iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.contentView.mas_left).offset(kProportion_Width(45));
        make.centerY.equalTo(weakSelf.contentView.mas_centerY);
        make.width.height.equalTo(@30);
    }];
    
    [titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(iconImageView.mas_centerY);
        make.left.equalTo(iconImageView.mas_right).offset(kProportion_Width(20));
        make.width.equalTo(@(150));
        make.height.equalTo(@(20));
    }];
    
    [arrowImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(iconImageView.mas_centerY);
        make.right.equalTo(weakSelf.contentView.mas_right).offset(-kProportion_Width(45));
        make.width.equalTo(@7);
        make.height.equalTo(@13);
    }];
    
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.contentView.mas_left).offset(kProportion_Width(45));
        make.right.equalTo(weakSelf.contentView.mas_right).offset(-kProportion_Width(45));
        make.bottom.equalTo(weakSelf.contentView.mas_bottom);
        make.height.equalTo(@(1));
    }];
    
}

-(void)setTitle:(NSString *)str andImage:(NSString *)imageStr andIndexPath:(NSIndexPath *)indexPath{
    iconImageView.image = [UIImage imageNamed:imageStr];
    [titleLab setText:str];
    
    if ((indexPath.section == 1 && indexPath.row == 0) || (indexPath.section == 2 && indexPath.row == 2) || (indexPath.section == 3 && indexPath.row == 2)) {//隐藏分割线
        lineView.hidden = YES;
    }
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
